<%@ page import="java.util.*, milu.*, milu.models.*,com.google.appengine.api.datastore.*" %>
<jsp:include page="/header.jsp" />

<%
MyUser thisUser = (MyUser)request.getAttribute("thisUser");
%>

<table class="user-detail" style="width: 950px;">
            <tbody><tr>
                <!--cell-->
                <td style="vertical-align: top; width: 170px; text-align: center;">
                    <%
                    Key avatarKey = thisUser.getAvatarKey();
                    if(avatarKey != null) {
                    %>
                    <img src="/serve/<%=avatarKey.getId()%>.png" />
                    <% } else { %>
                    <img src="/images/default-avatar.png" />

                    <% } %>
                </td>
                <!--cell-->
                <td style="vertical-align: top; width: 650px;">

<%
MyUser myUser = (MyUser)request.getAttribute("myUser");
if(myUser != null && myUser.getKey().equals(thisUser.getKey())) {
%>
<div style="float: right;" id="user-menu">
    <div id="account-recovery-form">
        <a href="/edit">Modifica</a>
    </div>
</div>
<% } %>
                    <table class="user-details">
                        <tbody><tr>
                            <td style="width: 120px;">
                                Nome
                            </td>
                            <td style="width: 230px;">
                                <b><%=thisUser.getName()%></b>
                            </td>
                        </tr>
                        
                    </tbody></table>
                </td>
            </tr>
        </tbody></table>


<div style="margin-top: 10px;"></div>

<div id="subheader">
    <div id="tabs">
        <a title="Top statistics for this user" href="/users/1396?tab=stats#sort-top" class="youarehere">Ricette</a>
        <!--<a title="Recent activity by this user" href="/users/1396?tab=recent#sort-top">Profilo</a>-->

    </div>
</div>
<div style="margin-top: 10px;"></div>

    <ul class="recipe_list large">
<% 
List<Recipe> recipes = (List<Recipe>)request.getAttribute("recipes");
int counter = 0;
for(Recipe recipe : recipes) {
    MyUser recipeUser = MyUser.getUserInfo(recipe.getUserKey());
    List<RecipeComment> comments = RecipeComment.getCommentsForRecipe(recipe.getKey());
    if(counter == 4) counter = 0;
    counter++;
%>
    <li class="<%=(counter == 4 ? "last":"")%>" style="background: url(/serve/<%=recipe.getThumbKey().getId()%>.png) no-repeat;" alt="<%=recipe.getTitle()%>">
        <a class="image" href="/recipes/<%=recipe.getKey().getId()%>">
        </a>
        <div class="owner">
            <h2><a class="title" href="/recipes/<%=recipe.getKey().getId()%>">
                <%=recipe.getTitle()%>
            </a></h2>
            <cite>
                by <a href="/users/<%=recipeUser.getKey().getId()%>"><%=recipeUser.getName()%></a>
                <em class="recipe_stats"><span class="recipe_stats_comment"><%=comments.size()%></span> </em>
            </cite>
        </div>
    </li>

<%
}
%>
    <div style="display:none">
        <p id="loading"><img alt="Spinner" src="/images/spinner.gif?1300093942" />Loading more movies...</p>
        <form style="display: none;"><input id="load_more_path" name="load_more_path" type="hidden" value="/page/" /></form>
    </div>
</ul>
<div class="page_break"></div>


<jsp:include page="/footer.jsp" />
